<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>p2_CSS选择器</title>
    <style>
        h4{
            color: red;
        }
        #d1{
            width: 100px;
            height: 100px;
            background-color: aqua;
        }
        .msg {
            color: white;
        }
        .success {
            background-color: green;
        }
        .error {
            background-color: red;
        }
        #d1:hover{
            background-color: lightblue;
        }
        a:link{
            color: green;
        }
        a:visited{
            color: darkgreen;
        }
        a:hover{
            color: greenyellow;
        }
        a:active{
            color: lawngreen;
        }
        select[name="username"]{
            background-color: cornflowerblue;
            color: white;
        }
        *{
            font-style: italic;
        }
        h4,#d1,.error{
            border: 5px solid purple;
        }
        #d2 span{
            background-color: lightskyblue;
        }
        #d2>div>p>span{
            color: orange;
        }
    </style>
</head>
<body>
    <div id="d1">我是div</div>
    <div></div>
    <p></p>
    <h4>我是h4</h4>
    <h4>我是h4</h4>
    <hr>
    <span class="error msg">用户名不能为空!</span>
    <span class="error msg">密码不能为空!</span>
    <span class="success msg">手机号格式正确!</span>
    <span class="success msg">邮箱格式正确!</span>
    <hr>
    <a href="https://www.baidu.com">超链接</a>
    <a href="http://www.abcccbacabcbabcbabcba.com">超链接</a>
    <hr>
    <input type="text" name="username">
    <input type="text" name="nickname">
    <select name="username">
        <option value="1">1</option>
        <option value="2">2</option>
    </select>
    <hr>
    <div id="d2">
        <span>111</span>
        <div>
            <span>222</span>
            <p>测试文字</p>
            <p>我是<span>333</span>段落</p>
        </div>
        <span>444</span>
    </div>
</body>
</html>